﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace YXShop.Web.admin.product
{
    public partial class onlinesignupinfo_list : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                
                    YXShop.Common.PromptInfo.Popedom("002001001");
                if (ChangeHope.WebPage.PageRequest.GetFormString("Option") != string.Empty && ChangeHope.WebPage.PageRequest.GetFormInt("id") > 0)
                {
                    string types = Request.Form["Option"].Trim();
                    int id = ChangeHope.WebPage.PageRequest.GetFormInt("id");
                    if (types == "del")
                    {
                        if(YXShop.Common.PromptInfo.Message("002001003")!="ok")
                        {
                        del(id);
                        }
                        else
                        {
                         Response.Write("no");
                        }
                    }
                    Response.End();
                    return;
                }
                if (ChangeHope.WebPage.PageRequest.GetQueryString("q_productid") != "")
                {
                    this.returnList.NavigateUrl = "sendgroupbuyinfo_list.aspx?w_d_productid=" + ChangeHope.WebPage.PageRequest.GetQueryString("q_productid");
                }
                GetList();
            }
        }
        /// <summary>
        /// 列表
        /// </summary>
        /// <returns></returns>
        protected void GetList()
        {
            YXShop.Common.SysParameter sp = new YXShop.Common.SysParameter();
            ChangeHope.WebPage.Table table = new ChangeHope.WebPage.Table();
            YXShop.BLL.Product.GroupBuy_OnlineSignUpInfo data = new YXShop.BLL.Product.GroupBuy_OnlineSignUpInfo();
            ChangeHope.DataBase.DataByPage dataPage = data.GetList();
            //第一步先添加表头
            table.AddHeadCol("10%", "编号");
            table.AddHeadCol("20%", "报名人");
            table.AddHeadCol("15%", "人数");
            table.AddHeadCol("20%", "报名时间");
            table.AddHeadCol("15%", "报名状态");
            table.AddHeadCol("20%", "操作");
            table.AddRow();
            //添加表的内容
            if (dataPage.DataReader != null)
            {
                while (dataPage.DataReader.Read())
                {
                    table.AddCol("No." + dataPage.DataReader["id"].ToString());
                    table.AddCol(dataPage.DataReader["name"].ToString());
                    table.AddCol(dataPage.DataReader["signupcount"].ToString());

                    table.AddCol(dataPage.DataReader["createtime"].ToString());
                    table.AddCol(dataPage.DataReader["state"].ToString() == "0" ? "未通过" : "通过");
                    table.AddCol(string.Format("<a href='onlinesignupinfo.aspx?id={0}&productid={1}'>详情</a>", dataPage.DataReader["id"].ToString(), ChangeHope.WebPage.PageRequest.GetQueryString("q_productid")));
                    table.AddRow();
                }
            }
            string view = table.GetTable() + dataPage.PageToolBar;
            dataPage.Dispose();
            dataPage = null;
            this.litInfo.Text = view;
        }


        private void del(int id)
        {
          
                YXShop.BLL.Product.GroupBuy_OnlineSignUpInfo bll = new YXShop.BLL.Product.GroupBuy_OnlineSignUpInfo();
                bll.Delete(id);
                Response.Write("ok");
            
        }
    }
}

